module.exports = function(grunt) {
	grunt.initConfig({
		pkg : grunt.file.readJSON('package.json'),
		uglify: {
	      	options: {
		        banner: '/*! <%= pkg.name %> build<%= grunt.template.today("yyyymmddhhMMss") %> */\n',
		        compress: {
					global_defs: {
						"DEBUG": false
					},
					drop_console: true,
					dead_code: true
				},
				mangle: true
		    },
		    build: {
		        files: [{
                    expand:true,
                    cwd:'./script/lib',//js目录下
                    src:'**/*.js',//所有js文件
                    dest: './script/release/lib'//输出到此目录下
                }]
		    }
	    },
	    clean: {
			build: ["./script/release/**/*"]
		},
	    requirejs:{
	    	mdm:{
	    		options:{
	    			baseUrl:"./script/mdm",
	    			dir:"./script/release/mdm",
	    			mainConfigFile: "./script/main_debug.js",
	    			optimize: 'uglify',
	    			removeCombined:true,
	    			// findNestedDependencies: true,
	    			logLevel: 1,
	    			modules:[
	    				{
	    					name:"menu",
	    					exclude:['common/render','common/constants','common/common','common/data']
	    				},
	    				{
	    					name:"device",
	    					exclude:['common/render','common/constants','common/common','common/data']
	    				},
	    				{
	    					name:"user",
	    					exclude:['common/render','common/constants','common/common','common/data']
	    				}
	    			]
	    		}
	    	},
	    	common:{
	    		options:{
	    			baseUrl:"./script/mdm/common",
	    			dir:"./script/release/mdm/common",
	    			optimize: 'uglify',
	    			findNestedDependencies: true,
	    			logLevel: 1,
	    			removeCombined:true
	    		}
	    	}
	    }
	});

	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-requirejs');

	// 注册任务
    grunt.registerTask('default', ['clean','uglify','requirejs:common','requirejs:mdm']);
};